using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using BoOnce.Core;
using Microsoft.Xna.Framework.Graphics;
using BoOnce.Core.Helpers;

namespace BoOnce.Core.Components
{
    public class StepTransitionComponent : DrawableGameComponent
    {
        private Step _CurrentStep;

        public StepTransitionComponent(Game game)
            : base(game)
        {
        }

        public override void Initialize()
        {
            Logger.WriteInfo("StepTransitionComponent["+this.UpdateOrder+"] init");
            base.Initialize();
        }

        public void GoTo(Step nextStep)
        {
            Logger.WriteInfo("Go to next step '" + nextStep.StepName +"'");
            if (_CurrentStep != null) {
                _CurrentStep.UnloadContent();
            }
            
            nextStep.LoadContent();
            _CurrentStep = nextStep;           
        }

        public override void Update(GameTime gameTime)
        {
            if (_CurrentStep != null)
            {
                _CurrentStep.Update(gameTime);
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            if (_CurrentStep != null)
            {
                _CurrentStep.Draw(gameTime);
            }
            base.Draw(gameTime);
        }
    }
}
